package com.xunshangwang.pinhaohuo.tools;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by xzp on 15/9/24.
 */
public class SPHelper {
    public final static String APP_START_COUNT="appStartCount";
    public final static String SCREEN_WIDTH_PIXELS="widthPixels";
    public final static String SCREEN_HEIGHT_PIXELS="heightPixels";
    public final static String IS_LOGIN="isLogin";
    /**
     * SP_CONFIG字段:
     * appStartCount 应用启动次数 int
     * widthPixels 屏幕水平像素 int
     * heightPixels 屏幕垂直像素 int
     * isLogin 用户是否登录 boolean
     */
    public static final String SP_CONFIG="config";

    /**
     *
     */
    public static final String SP_ACCOUNT="account";

    public static final int getIntValue(Context context,String name,String key){
        SharedPreferences preferences=context.getSharedPreferences(name,Context.MODE_PRIVATE);
        return preferences.getInt(key,0);
    }
    public static final String getStringValue(Context context,String name,String key){
        SharedPreferences preferences=context.getSharedPreferences(name,Context.MODE_PRIVATE);
        return preferences.getString(key, null);
    }
    public static final boolean getBooleanValue(Context context,String name,String key){
        SharedPreferences preferences=context.getSharedPreferences(name,Context.MODE_PRIVATE);
        return preferences.getBoolean(key,false);
    }
}
